{% extends 'index.html' %}

{% block head %}
<style type="text/css">
    .display_none{display: none;}
</style>

{% endblock %}

{% block bodyweigh %}
<body style="width: 1200px;">
{% endblock %}

{% block content %}
        <div id="check" class="display_none" style="width: 400px;height: 600px;"><button type="button" style="color: #000;" id="yes">确定</button> &nbsp;&nbsp;
            <button type="button" style="color: #000;" id="no">返回</button>
        </div>
    <!-- 右侧主体开始 -->
        <div class="page-content" >
          <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <!-- <form class="layui-form xbs" action="" >
                <div class="layui-form-pane" style="text-align: center;">
                  <div class="layui-form-item" style="display: inline-block;">
                    <label class="layui-form-label xbs768">日期范围</label>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
                    </div>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
                    </div>
                    <div class="layui-input-inline">
                      <input type="text" name="username"  placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form> -->
            <xblock><button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon">&#xe640;</i>批量删除</button>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>
                            用户类型
                        </th>
                        <th>
                            登陆时间(可不填)
                        </th>
                        <th>
                            消息内容
                        </th>                   
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody id="message">
                    <td>
                        <select style="color: #000;" id="select"> <option value ="1" style="color: #000;">全部用户</option><option style="color: #000;" value ="2">贴吧用户</option><option style="color: #000;" value ="3">非贴吧用户</option></select><input type="hidden" id="type" value="1"/> 
                    </td>
                    <td>                      
                        <input type="text" size="7" style="color: #000;" id="day"/>天内登陆过
                    </td>                       
                    <td> 
                        <textarea id="content" style="color: #000;"></textarea>
                    </td>                        
                    <td class="td-manage">
                        <button type="button" style="color: #000;" id="send">发送</button>
                    </td>
                </tbody>
            </table>
            <!-- 右侧内容框架，更改从这里结束 -->
          </div>
        </div>
        <!-- 右侧主体结束 -->
{% endblock %}

{% block script %}
 <!-- 页面动态效果 -->
    <script>

        layui.use(['laydate'], function(){
          laydate = layui.laydate;//日期插件

          //以上模块根据需要引入
          //
          

          
          var start = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
              end.min = datas; //开始日选好后，重置结束日的最小日期
              end.start = datas //将结束日的初始值设定为开始日
            }
          };
          
          var end = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
              start.max = datas; //结束日选好后，重置开始日的最大日期
            }
          };
          
          document.getElementById('LAY_demorange_s').onclick = function(){
            start.elem = this;
            laydate(start);
          }
          document.getElementById('LAY_demorange_e').onclick = function(){
            end.elem = this
            laydate(end);
          }
          
        });

        //批量删除提交
         function delAll () {
            layer.confirm('确认要删除吗？',function(index){
                //捉到所有被选中的，发异步进行删除
                layer.msg('删除成功', {icon: 1});
            });
         }

        </script>

        

        <script>

            $("#day").keyup(function(){
                 var c=$(this);  
                 if(/[^\d]/.test(c.val())){//替换非数字字符  
                  var temp_amount=c.val().replace(/[^\d]/g,'');  
                  $(this).val(temp_amount);  
                 }  
            })

            $("#select").on("click",function(){
                var type = $("#select option:selected").val();
                $(this).next().val(type);
            });

            $("#send").on("click",function() {



                // $("#check").removeClass("display_none");

                // $("#yes").on("click",function(){

                    var type = $("#type").val();
                    var day = $("#day").val();    
                    var content = $("#content").val();    
                  
                    if (content == ""){
                        alert('请填写消息内容');
                        return false;
                    }

                    params = {
                    "type":type,
                    "day":day,           
                    "content":content,     
                    };

                    $.ajax({
                        url:"/app/user_message/sending",
                        type:"POST",
                        data:JSON.stringify(params),
                        contentType:'application/json',
                        success:function(res){
                            if(res.status == 0){
                                alert(res.msg);
                                location.href="/app/user_message/send";
                            }else {
                                alert(res.msg);
                            }
                        }
                    })
                    
                });

                // $("#no").on("click",function(){
                //     $("#check").addClass("display_none");
                // });

            // });
        


        </script>>
{% endblock %}